package com.wlb365.admin.modules.schedule.utils;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.Date;

/**
 * <p>
 * 概述：
 * </p>
 *
 * @author zwh
 * @version 1.0
 * @copyRight 北京微利宝信息技术有限公司  All right reserved.
 * @date 2020/5/22
 */
public class DateUtil {
    private static DateTimeFormatter dateTimeFormat = DateTimeFormatter.ofPattern("yyyyMMdd");

    public static String getDateStr() {
        return LocalDate.now().format(dateTimeFormat);
    }

    public static String getDateStr(LocalDate localDate) {
        return localDate.format(dateTimeFormat);
    }


    public static LocalDateTime getDateTimeOfTimestamp(long timestamp) {
        Instant instant = Instant.ofEpochMilli(timestamp);
        ZoneId zone = ZoneId.systemDefault();
        return LocalDateTime.ofInstant(instant, zone);
    }
}
